package com.ccys.cms.service.inventory.impl;

import com.ccys.cms.service.inventory.ExchangeOrderService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.web.inventory.ExchangeOrderPageDto;
import com.ccys.db.entity.TblPurchaseOrder;
import com.ccys.db.mapper.TblPurchaseOrderMapper;
import com.ccys.db.page.PageDto;
import com.ccys.db.rely.service.impl.BaseServiceImpl;
import com.ccys.db.vo.web.inventory.ExchangeOrderVo;
import com.ccys.db.vo.web.inventory.PurchaseOrderVo;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
@Slf4j
public class ExchangeOrderServiceImpl extends BaseServiceImpl<TblPurchaseOrder> implements ExchangeOrderService {

    @Resource
    private TblPurchaseOrderMapper mapper;

    @Override
    public ResponseResult getPage(ExchangeOrderPageDto dto) {
        //根据当前用户groupid
        //超级管理员的区分 (超级管理员没有groupId 不会进查询条件)
        if (StringUtils.isEmpty(dto.getGroupId())) {
            String groupId = dto.getGroupId();
            dto.setGroupId(groupId);
        }
        PageDto.startPage();
        List<ExchangeOrderVo> list = mapper.getExchangeList(dto);
        PageInfo<ExchangeOrderVo> info = new PageInfo<>(list);
        return ResponseResult.success(info);
    }
}
